using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
using System;
namespace WPFExcelReport
{
    public partial class VTXTIND
    {
        public VHELP VHP
        {
            get
            {
                if (!ENVMAIN.ContainsKey("VHP"))
                    ENVMAIN["VHP"] = new VHELP();
                return (VHELP)ENVMAIN["VHP"];
            }
        }
        public VTXTKON VTKON
        {
            get
            {
                if (!ENVMAIN.ContainsKey("VTKON"))
                    ENVMAIN["VTKON"] = new VTXTKON();
                return (VTXTKON)ENVMAIN["VTKON"];
            }
        }
        public static readonly VTXTIND Instance = new VTXTIND();
        public override void SetUp()
        {
            base.SetUp();
        } 
        private string _TART = ""; public string TART { get { return _TART; } set { _TART = value; OnPropertyChanged("TART", value); } }
        private string _PIND = ""; public string PIND { get { return _PIND; } set { _PIND = value; OnPropertyChanged("PIND", value); } }
        private string _SIND = ""; public string SIND { get { return _SIND; } set { _SIND = value; OnPropertyChanged("SIND", value); } }

        public double GetMaxID(DataRow dwInput)
        {
            double ID = 0;
            DataSet SResult = new DataSet();
            SResult = QueryTXTIND(dwInput, 3);
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                ID = System.Convert.ToDouble(row["TXTIPIND"].ToString());
            }
            ID++;
            return ID;
        }
        public double  InsertTXT(string sind, string tart)
        { 
            dwData = TBMain.NewRow();
            SetUpNewRow(ref dwData, null);
            dwData["TXTIMANDANT"] = app.Mandant;
            double maxid = Instance.GetMaxID(dwData);
            maxid++;
            dwData["TXTITXTART"] = tart;
            dwData["TXTISIND"] = sind;
            dwData["TXTIPIND"] = maxid;
            dwData["TXTINEUBEN"] = app.User;
            dwData["TXTINEUDAT"] = date;
            dwData["TXTIUPDT"] = "J";
            InsertTXTIND(dwData, app.company);
            TBMain.Rows.InsertAt(dwData, 0);
            return maxid;
        }
        public void BATCHBOXTEX(string sind,string tart,string Text,bool IsAuto=true)
        {
            string pind=(LOADBYSIND(sind, tart, IsAuto)).ToString();
            VTKON.IsTXTBox = true;
            VTKON.PIND = pind;
            VTKON.PushText(pind, Text,true);
        }
        public void BATCHREMOVETEX(string sind, string tart)
        {
            dwData = TBMain.NewRow();
            dwData["TXTIMANDANT"] = app.Mandant;
            dwData["TXTITXTART"] = tart;
            dwData["TXTISIND"] = " AND SUBSTR(TXTISIND,1,5)='"+sind+"'";
           DTXTIND01(dwData);
        }
        public void BATCHBOXTEX(string sind, string tart, string Text, bool IsDeduct,bool IsAuto = true)
        {
            BATCHBOXTEX(sind, tart, Text, false, IsAuto);
        }
        public double LOADBYSIND(string sind,string tart,bool IsAuto)
        {
            if (TBMain == null)
                return -1;
            TBMain.Clear();
            if (sind.Length < 10)
            {
                return-1;
            }
            dwData = TBMain.NewRow();
            dwData["TXTIMANDANT"] = app.Mandant;
            dwData["TXTITXTART"] = tart;
            dwData["TXTISIND"] = sind;
            SResult = QTXTIND02(dwData);
            MergeData(SResult, true);
            if (!IsAuto)
                return -1;
            if (SResult.Tables[0].Rows.Count > 0)
                return double.Parse(SResult.Tables[0].Rows[0]["TXTIPIND"].ToString());
          return  InsertTXT(sind, tart);
           
        }
    }
    public partial class VTXTIND
    {
        /*
        public string TXTIMANDANT { get { if (dwMaster == null) return ""; return dwMaster["TXTIMANDANT"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTIMANDANT"] = value; OnPropertyChanged("TXTIMANDANT", value); } } //lENGth 2
        public string TXTITXTART { get { if (dwMaster == null) return ""; return dwMaster["TXTITXTART"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTITXTART"] = value; OnPropertyChanged("TXTITXTART", value); } } //lENGth 3
        public string TXTISIND { get { if (dwMaster == null) return ""; return dwMaster["TXTISIND"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTISIND"] = value; OnPropertyChanged("TXTISIND", value); } } //lENGth 60
        public string TXTISPRACHKZ { get { if (dwMaster == null) return ""; return dwMaster["TXTISPRACHKZ"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTISPRACHKZ"] = value; OnPropertyChanged("TXTISPRACHKZ", value); } } //lENGth 2
        public double TXTIPIND { get { if (dwMaster == null) return 0.0; return Convert.ToDouble(dwMaster["TXTIPIND"].ToString()); } set { if (dwMaster == null) return; dwMaster["TXTIPIND"] = value; OnPropertyChanged("TXTIPIND", value); } } //lENGth 0
        public string TXTITITEL { get { if (dwMaster == null) return ""; return dwMaster["TXTITITEL"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTITITEL"] = value; OnPropertyChanged("TXTITITEL", value); } } //lENGth 30
        public string TXTINURERGAENZ { get { if (dwMaster == null) return ""; return dwMaster["TXTINURERGAENZ"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTINURERGAENZ"] = value; OnPropertyChanged("TXTINURERGAENZ", value); } } //lENGth 1
        public string TXTISAPTEXTART { get { if (dwMaster == null) return ""; return dwMaster["TXTISAPTEXTART"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTISAPTEXTART"] = value; OnPropertyChanged("TXTISAPTEXTART", value); } } //lENGth 4
        public string TXTISTARTENDE { get { if (dwMaster == null) return ""; return dwMaster["TXTISTARTENDE"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTISTARTENDE"] = value; OnPropertyChanged("TXTISTARTENDE", value); } } //lENGth 1
        public string TXTIKZPERS { get { if (dwMaster == null) return ""; return dwMaster["TXTIKZPERS"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTIKZPERS"] = value; OnPropertyChanged("TXTIKZPERS", value); } } //lENGth 1
        public string TXTIAENDBEN { get { if (dwMaster == null) return ""; return dwMaster["TXTIAENDBEN"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTIAENDBEN"] = value; OnPropertyChanged("TXTIAENDBEN", value); } } //lENGth 8
        public double TXTIAENDDAT { get { if (dwMaster == null) return 0.0; return Convert.ToDouble(dwMaster["TXTIAENDDAT"].ToString()); } set { if (dwMaster == null) return; dwMaster["TXTIAENDDAT"] = value; OnPropertyChanged("TXTIAENDDAT", value); } } //lENGth 0
        public string TXTINEUBEN { get { if (dwMaster == null) return ""; return dwMaster["TXTINEUBEN"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTINEUBEN"] = value; OnPropertyChanged("TXTINEUBEN", value); } } //lENGth 8
        public double TXTINEUDAT { get { if (dwMaster == null) return 0.0; return Convert.ToDouble(dwMaster["TXTINEUDAT"].ToString()); } set { if (dwMaster == null) return; dwMaster["TXTINEUDAT"] = value; OnPropertyChanged("TXTINEUDAT", value); } } //lENGth 0
        public double TXTIAENDZL { get { if (dwMaster == null) return 0.0; return Convert.ToDouble(dwMaster["TXTIAENDZL"].ToString()); } set { if (dwMaster == null) return; dwMaster["TXTIAENDZL"] = value; OnPropertyChanged("TXTIAENDZL", value); } } //lENGth 0
        public double TXTILPOS { get { if (dwMaster == null) return 0.0; return Convert.ToDouble(dwMaster["TXTILPOS"].ToString()); } set { if (dwMaster == null) return; dwMaster["TXTILPOS"] = value; OnPropertyChanged("TXTILPOS", value); } } //lENGth 0
        public string TXTIUPDT { get { if (dwMaster == null) return ""; return dwMaster["TXTIUPDT"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTIUPDT"] = value; OnPropertyChanged("TXTIUPDT", value); } } //lENGth 1
        public string TXTIRICHEDIT { get { if (dwMaster == null) return ""; return dwMaster["TXTIRICHEDIT"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTIRICHEDIT"] = value; OnPropertyChanged("TXTIRICHEDIT", value); } } //lENGth 1
        public string TXTIFILLER { get { if (dwMaster == null) return ""; return dwMaster["TXTIFILLER"].ToString(); } set { if (dwMaster == null) return; dwMaster["TXTIFILLER"] = value; OnPropertyChanged("TXTIFILLER", value); } } //lENGth 20
        */
    }
}
